﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Web.Mvc;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

namespace VehicleManagement.Models
{
    //    ----------司机表--------司机ID属性和申请审批表中的司机ID一致
    //CREATE	TABLE DriverInfo
    //(
    //DriverID int  IDENTITY(1,1) primary key,
    //Driver_name varchar(18)  not null,
    //Driver_image varchar(100),
    //Email varchar(30),
    //Sex  char(2),
    //Age  int,
    //Telephone varchar(18),
    //Fam_addr varchar(30),
    //Free_busy bit default(0),
    //isMane bit default(0),
    //Driver_linceID varchar(18) unique not null ,
    //LinceID  varchar(18) unique not null,
    //Lince_start datetime not null,
    //Lince_type varchar(18) not null,
    //Lincecheck_time datetime not null,
    //Remark  varchar(100)
    //)
    public class DriverInfo
    {
        [DisplayName("司机编号")]
        public int DriverID { get; set; }


        [DisplayName("司机号码")]
        //  [Required(ErrorMessage="请输入1到18位数字或字母")]
        //  [RegularExpression(@"^[-\da-zA-Z]{1,18}$", ErrorMessage = "请输入1到18位数字或字母")]
        public virtual string DriverNumber { get; set; }


        [DisplayName("司机姓名")]
        [Required(ErrorMessage = "司机姓名不能为空")]
        [Remote("CheckUserAccountExists", "Driver", ErrorMessage = "用户账号已存在", AdditionalFields = "DriverID")] // 远程验证
        [StringLength(18, ErrorMessage = "姓名不能超过18位")]
        public string DriverName { get; set; }

        [DisplayName("密码")]
        // [Required(ErrorMessage = "密码不能为空")]
        [StringLength(18, ErrorMessage = "密码不能超过18位")]
        public string Password { get; set; }

        [DisplayName("密保问题")]
        [StringLength(18, ErrorMessage = "问题不能超过18位")]
        public string Question { get; set; }

        [DisplayName("密保答案")]
        [StringLength(18, ErrorMessage = "答案不能超过18位")]
        public string Answer { get; set; }



        [DisplayName("司机照片")]
        //[Required(ErrorMessage = "车照片不能为空")]
        //[StringLength(18 , ErrorMessage = "车照片长度不能超过18位")]
        public string DriverImage { get; set; }

        [DisplayName("邮箱地址")]
        [Remote("CheckEmailExists", "Driver", ErrorMessage = "该邮箱已存在", AdditionalFields = "DriverID")] // 远程验证
        [Required(ErrorMessage = "邮箱不能为空")]
        [RegularExpression(@"^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$", ErrorMessage = "邮箱格式不正确")]       
        public string Email { get; set; }


        [DisplayName("性别")]
        //[Required(ErrorMessage = "车状态不能为空")]
        [StringLength(2, ErrorMessage = "性别不能超过2位")]
        public string Sex { get; set; }

        [DisplayName("年龄")]
        [Required(ErrorMessage = "年龄不能为空")]
        //[Range(typeof(System .Int32) , "1" , "100" , ErrorMessage = "用户年龄必须在1~100之间的整数")]
        public int Age { get; set; }


        [DisplayName("联系电话")]
        [Required(ErrorMessage = "电话不能为空")]
        [Remote("CheckTelephoneExists", "Driver", ErrorMessage = "该号码已存在", AdditionalFields = "DriverID")] // 远程验证
        [StringLength(18, ErrorMessage = "电话不能超过18位")]
        [RegularExpression(@"((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)", ErrorMessage = "号码格式不正确")]
        public string Telephone { get; set; }

        [DisplayName("家庭地址")]
        [Required(ErrorMessage = "地址不能为空")]
        [StringLength(30, ErrorMessage = "地址不能超过30位")]
        public string FamilyAddress { get; set; }


        [DisplayName("状态")]
        //[StringLength(2 , ErrorMessage = "状态长度不能超过2位")]
        public int FreeOrBusy { get; set; }

        [DisplayName("是否负责人")]
        // [StringLength(2 , ErrorMessage = "长度不能超过2位")]
        public int IsManeger { get; set; }



        [DisplayName("驾驶证号")]
        [Required(ErrorMessage = "号码不能为空")]
        [StringLength(18, ErrorMessage = "号码不能超过18位")]
        public string DriverLinceId { get; set; }


        [DisplayName("驾照档案号")]
        [Required(ErrorMessage = "号码不能为空")]
        [StringLength(18, ErrorMessage = "号码不能超过18位")]
        public string LinceID { get; set; }

        [DisplayName("发证日期")]
        [Required(ErrorMessage = "发证日期不能为空")]
        public DateTime LinceStart { get; set; }

        [DisplayName("准驾车型")]
        [Required(ErrorMessage = "车型不能为空")]
        [StringLength(18, ErrorMessage = "车型不能超过18位")]
        public string LinceType { get; set; }



        [DisplayName("年审日期")]
        [Required(ErrorMessage = "年审日期不能为空")]
        public DateTime LincecheckTime { get; set; }

        [DisplayName("备注")]
        [StringLength(100, ErrorMessage = "备注不能超过100位")]
        public string Remark { get; set; }

        public string CompanyName { get; set; }

        //public class CheckUserAccountExists : ValidationAttribute
        //{
        //    public override bool IsValid(object value)
        //    {
        //        bool exists = CheckUserAccountExists(value.ToString());
        //        return !exists;
        //    }

        //}

      


        /// <summary>
        /// 获取司机的状态
        /// </summary>
        /// <returns>返回司机的状态</returns>
        public List<SelectListItem> getDriverState()
        {
            //创建新元素
            List<SelectListItem> P_Item = new List<SelectListItem>();

            //设置默认数据
            P_Item.Add(new SelectListItem() { Text = "空闲", Value = "0", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "忙碌", Value = "1", Selected = true });
            //P_Item.Add(new SelectListItem() { Text = "事假", Value = "3", Selected = true });
            return P_Item;
        }

        /// <summary>
        /// 获取车辆类型
        /// </summary>
        /// <returns>返回车辆的类型</returns>
        public List<SelectListItem> getCarType()
        {
            //创建新元素
            List<SelectListItem> P_Item = new List<SelectListItem>();

            //设置默认数据
            P_Item.Add(new SelectListItem() { Text = "A1大型客车", Value = "A1大型客车", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "A2牵引车", Value = "A2牵引车", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "A3城市公交车", Value = "A3城市公交车", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "B1中型客车", Value = "B1中型客车", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "B2大型货车", Value = "B2大型货车", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "C1小型汽车", Value = "C1小型汽车", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "C2小型自动挡汽车", Value = "C2小型自动挡汽车", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "C3低速载货汽车", Value = "C3低速载货汽车", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "C4三轮汽车", Value = "C4三轮汽车", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "D普通三轮摩托车", Value = "D普通三轮摩托车", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "E普通二轮摩托车", Value = "E普通二轮摩托车", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "F轻便摩托车", Value = "F轻便摩托车", Selected = true });
            return P_Item;
        }


        public SelectList getSelectLinceType()
        {
            return new SelectList(new[] { "A1大型客车", "A2牵引车", "A3城市公交车", "B1中型客车", "B2大型货车", "C1小型汽车", "C2小型自动挡汽车", "C3低速载货汽车", "C4三轮汽车", "D普通三轮摩托车", "E普通二轮摩托车", "F轻便摩托车" });
        }


        public List<SelectListItem> getDriverAge()
        {
            //创建新元素
            List<SelectListItem> P_Item = new List<SelectListItem>();

            //设置默认数据
            P_Item.Add(new SelectListItem() { Text = "1", Value = "1", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "2", Value = "2", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "3", Value = "3", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "4", Value = "4", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "5", Value = "5", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "6", Value = "6", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "7", Value = "7", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "8", Value = "8", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "9", Value = "9", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "10", Value = "10", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "11", Value = "11", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "12", Value = "12", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "13", Value = "13", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "14", Value = "14", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "15", Value = "15", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "16", Value = "16", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "17", Value = "17", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "18", Value = "18", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "19", Value = "19", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "20", Value = "20", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "21", Value = "21", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "22", Value = "22", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "23", Value = "23", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "24", Value = "24", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "25", Value = "25", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "26", Value = "26", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "27", Value = "27", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "28", Value = "28", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "29", Value = "29", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "30", Value = "30", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "31", Value = "31", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "32", Value = "32", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "33", Value = "33", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "34", Value = "34", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "35", Value = "35", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "36", Value = "36", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "37", Value = "37", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "38", Value = "38", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "39", Value = "39", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "40", Value = "40", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "41", Value = "41", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "42", Value = "42", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "43", Value = "43", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "44", Value = "44", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "45", Value = "45", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "46", Value = "46", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "47", Value = "47", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "48", Value = "48", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "49", Value = "49", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "50", Value = "50", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "51", Value = "51", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "52", Value = "52", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "53", Value = "53", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "54", Value = "54", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "55", Value = "55", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "56", Value = "56", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "57", Value = "57", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "58", Value = "58", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "59", Value = "59", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "60", Value = "60", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "61", Value = "61", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "62", Value = "62", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "63", Value = "63", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "64", Value = "64", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "65", Value = "65", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "66", Value = "66", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "67", Value = "67", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "68", Value = "68", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "69", Value = "69", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "70", Value = "70", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "71", Value = "71", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "72", Value = "72", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "73", Value = "73", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "74", Value = "74", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "75", Value = "75", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "76", Value = "76", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "77", Value = "77", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "78", Value = "78", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "79", Value = "79", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "80", Value = "80", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "81", Value = "81", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "82", Value = "82", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "83", Value = "83", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "84", Value = "84", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "85", Value = "85", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "86", Value = "86", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "87", Value = "87", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "88", Value = "88", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "89", Value = "89", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "90", Value = "90", Selected = true });
    
            P_Item.Add(new SelectListItem() { Text = "91", Value = "91", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "92", Value = "92", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "93", Value = "93", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "94", Value = "94", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "95", Value = "95", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "96", Value = "96", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "97", Value = "97", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "98", Value = "98", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "99", Value = "99", Selected = true });
            P_Item.Add(new SelectListItem() { Text = "100", Value = "100", Selected = true });
            return P_Item;
 
        }


    }
}